package com.imut.oa.controller.admin;

import com.imut.oa.common.BaseResponse;
import com.imut.oa.common.ResultUtils;
import com.imut.oa.service.HomeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/home")
@Slf4j
@Tag(name = "首页数据")
public class HomeController {
    @Autowired
    private HomeService homeService;
    /**
     * 获取所有趋势数据
     *
     * @return
     */
    @GetMapping("/trend")
    public BaseResponse<Map<String, Long>> getAllTrendData() {
        Map<String, Long> result = homeService.getAllTrendData();
        return ResultUtils.success(result);
    }


    // 获取部门人员分布
    @GetMapping("/departmentStats")
    public BaseResponse<List<Map<String, Object>>> getDepartmentStats() {
        List<Map<String, Object>> stats = homeService.getDepartmentStats();
        return ResultUtils.success(stats);
    }

    // 获取考勤统计数据
    @GetMapping("/attendanceStats")
    public BaseResponse<Map<String, Object>> getAttendanceStats() {
        Map<String, Object> stats = homeService.getAttendanceStats();
        return ResultUtils.success(stats);
    }
}

